home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / wais / x / tcommands.c < prev    next >
C/C++ Source or Header  |  1995-05-09  |  4KB  |  174 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    This is part of the X user-interface for the WAIS software.  Do with it
  6.    as you please.
  7.  
  8.    jonathan@Think.COM
  9.  *
  10.  * $Log:    tcommands.c,v $
  11.  * Revision 1.6  92/04/28  15:31:18  jonathan
  12.  * Cleaned up use of scrollList.
  13.  * 
  14.  * Revision 1.5  92/03/17  14:17:18  jonathan
  15.  * Generally cleaned up.
  16.  * 
  17.  */
  18.  
  19. #ifndef lint
  20. static char *RCSid = "$Header: /tmp_mnt/net/quake/proj/wais/wais-8-b5/x/RCS/tcommands.c,v 1.6 92/04/28 15:31:18 jonathan Exp $";
  21. #endif
  22.  
  23. #define _C_TCOMMANDS
  24. #define XWAIS
  25. #include "xwais.h"
  26.  
  27. static Boolean editting_new_question;
  28. static int last_question = NO_ITEM_SELECTED;
  29. extern int last_source;
  30.  
  31. int get_selected_question()
  32. {
  33.   return(get_selected_item(questionwindow->ListWidget));
  34. }
  35.  
  36. /* ARGSUSED */
  37. void
  38. EditQuestion(w, closure, call_data)
  39. Widget w;
  40. XtPointer closure, call_data;
  41. {
  42.   char msg[STRINGSIZE];
  43.   int CurrentQuestion;
  44.  
  45.   double_click = FALSE;
  46.   LastClicked = w;
  47.  
  48.   if((CurrentQuestion = get_selected_question())
  49.      != NO_ITEM_SELECTED) {
  50.     if (CurrentQuestion == last_question) {
  51.       sprintf(msg, "Opening question: %s\n", Question_items[CurrentQuestion]);
  52.       XwaisPrintf(msg);
  53.       sprintf(msg, "xwaisq \"%s\" &", Question_items[CurrentQuestion]);
  54.       system(msg);
  55.     }
  56.     else last_question = CurrentQuestion;
  57.   }
  58.   else {
  59.     last_question = -1;
  60.     if (NumQuestions > 0)
  61.       XwaisPrintf("No question selected.\nPlease select one and try again.\n");
  62.     else {
  63.       XwaisPrintf("Opening new question\n");
  64.       system("xwaisq &");
  65.     }
  66.   }
  67. }
  68.  
  69. /* ARGSUSED */
  70. void
  71. AddQuestion(w, closure, call_data)
  72. Widget w;
  73. XtPointer closure, call_data;
  74. {
  75.   Question new;
  76.  
  77.   double_click = FALSE;
  78.   LastClicked = w;
  79.  
  80.   XwaisPrintf("Opening new question\n");
  81.   system("xwaisq &");
  82. }
  83.  
  84. void
  85. DeleteQuestion(w, closure, call_data)
  86. Widget w;
  87. XtPointer closure, call_data;
  88. {
  89.   char msg[STRINGSIZE];
  90.   int CurrentQuestion;
  91.  
  92.   double_click = FALSE;
  93.   LastClicked = w;
  94.  
  95.   if((CurrentQuestion = get_selected_question())
  96.      != NO_ITEM_SELECTED) {
  97.     sprintf(msg, "%s%s",
  98.         app_resources.questionDirectory,
  99.         Question_items[CurrentQuestion]);
  100.     if(unlink(msg) != 0)
  101.       XwaisPrintf("Error delete Question.\n");
  102.  
  103.     last_question = NO_ITEM_SELECTED;
  104.     ScanDirs(NULL, NULL);
  105.   }
  106.   else
  107.     XwaisPrintf("No question selected.\nPlease select one and try again.\n");
  108. }
  109.  
  110. void
  111. DeleteSource(w, closure, call_data)
  112. Widget w;
  113. XtPointer closure, call_data;
  114. {
  115.   char msg[STRINGSIZE];
  116.  
  117.   double_click = FALSE;
  118.   LastClicked = w;
  119.  
  120.   if(get_selected_source() != NO_ITEM_SELECTED) {
  121.     sprintf(msg, "%s%s",
  122.         app_resources.userSourceDirectory,
  123.         Source_items[get_selected_source()]);
  124.  
  125.     if (unlink(msg) != 0)
  126.       XwaisPrintf("Error deleting source.\n");
  127.     else {
  128.       last_source = NO_ITEM_SELECTED;
  129.       XawListUnhighlight(sourcewindow->ListWidget);
  130.     }
  131.   }
  132.   else
  133.     XwaisPrintf("No source selected.\nPlease select one and try again.\n");
  134. }
  135.  
  136. static Widget helpwindow = NULL;
  137.  
  138. void EndHelp(w, closure, call_data)
  139. Widget w;
  140. XtPointer closure, call_data;
  141. {
  142.   XtPopdown(helpwindow);
  143. }
  144.  
  145. void XwaisHelp(w, closure, call_data)
  146. Widget w;
  147. XtPointer closure, call_data;
  148. {
  149.   Widget textwindow, frame, button;
  150.   Arg arglist[10];
  151.   Cardinal num_args;
  152.   static String items[] = {NULL};
  153.  
  154.   if (helpwindow == NULL) {
  155.     num_args = 0;
  156.     XtSetArg(arglist[num_args], XtNtitle, "X WAIS Help"); num_args++;
  157.     XtSetArg(arglist[num_args], XtNiconName, "X WAIS Help"); num_args++;
  158.     helpwindow = XtCreatePopupShell("textpopup", applicationShellWidgetClass,
  159.                     XtParent(w), arglist, num_args);
  160.     frame =
  161.       XtCreateManagedWidget("helppopupform", formWidgetClass,
  162.                 helpwindow, NULL, ZERO);
  163.     num_args = 0;
  164.     XtSetArg(arglist[num_args], XtNtype, XawAsciiFile); num_args++;
  165.     XtSetArg(arglist[num_args], XtNstring, app_resources.helpFile); num_args++;
  166.     XtSetArg(arglist[num_args], XtNeditType, XawtextRead); num_args++;
  167.     textwindow =
  168.       XtCreateManagedWidget("textWindow", asciiTextWidgetClass, frame, arglist, num_args);
  169.     button = MakeCommandButton(frame, "tdone", EndHelp, textwindow, NULL, NULL);
  170.     SetIcon(helpwindow);
  171.   }
  172.   XtPopup(helpwindow, XtGrabNone);
  173. }
  174.